<html>
<head>
    <title>qJST Tester</title>
    <script>imagePath='../images/';wrroot='../';contextPath='../';bDebug=true</script>
    <script src="../qCore.js"></script>
    <script src="../qBase.js"></script>
    <style>
    </style>
    <script>
        bDebug=true
        _MySpec = [
             [ "Name", "fld1" ] 
            ,[ "Name", "fld2" ]
            ,[ "Name", "fld3", "key", true ]
            ,[ "Name", "fld4", "DType", "date" ]
        ]
        
        function bodyLoaded(){
            
z            qdate_test()
            
//            doSimpleTest()
            
//            keyTests_doTest()
            
        }
        
        function qdate_test(){
//            s = "12-31-1969 19:00:00 GMT+0000"
            s = "1/01/2008 24:00:00 GMT-0500"
            pc("s = "+s)
            
            qd = new QDate(s)
            pc("qd = "+qd)
            s2 = qd.toString()
            
            qd2 = new QDate(s2)  
            pc("qd2 = "+qd2)
            
            qd3 = new QDate(q$.NULLDATE)  
            pc("qd3 = "+qd3)
            
//// http://articles.techrepublic.com.com/5100-3513-6016329.html
//function calcTime(city, offset) {
//
//    // create Date object for current location
//    d = new Date();
//   
//    // convert to msec
//    // add local time zone offset
//    // get UTC time in msec
//    utc = d.getTime() + (d.getTimezoneOffset() * 60000);
//   
//    // create new Date object for different city
//    // using supplied offset
//    nd = new Date(utc + (3600000*offset));
//pc("tzo = "+nd.getTimezoneOffset())
//   
//    // return time as a string
//    return "The local time in " + city + " is " + nd.toLocaleString();
//
//}
//
//        // get Bombay time
//        pc(calcTime('Bombay', '+5.5'));
//        
//        // get Singapore time
//        pc(calcTime('Singapore', '+8'));
//        
//        // get London time
//        pc(calcTime('London', '+1'));
            
            
        }
        
      // Tests
        function doSimpleTest(){
            _w.oJST=JNull()
            buildJSTable("_w.oJST", _MySpec, [
                 ["r1f1", "r1f2", "r1f3", "1/01/2008 24:00:00 GMT-0500"]
//                 ["r1f1", "r1f2", "r1f3", "12-31-1969 19:00:00 GMT-0500"]
//                ,["r2f1", "r2f2", "r2f3"]
//                ,["r3f1", "r3f2", "r3f3"]
            ])
            
            pc("oJST.length = "+oJST.length)
            pc(oJST[0].fld4)
            pc(oJST[0].toArray())
            
            buildJSRecord("_w.oJSR", _MySpec, oJST[0].toArray())
            pc(_w.oJSR)
            buildJSRecord("_w.oJSR2", _MySpec, _w.oJSR.toArray())
            pc(_w.oJSR2)
            pc(_w.oJSR2.fld4.format(q$.DATETIME_FORMAT))
            
            
        }
        
      // Key Tests
        function keyTests_doTest(){
            buildJSTable("_w.oJST", _MySpec, [
                 ["r1f1", "r1f2", "r1f3"]
                ,["r2f1", "r2f2", "r2f3"]
                ,["r3f1", "r3f2", "r3f3"]
            ])
            
            
//            iRec = oJST.getRecordIndex("r3f3")
//            debug("iRec = "+iRec)

            
//            debug(oJST.key)
            
//          // Get Record
//            oRec = oJST.getRecord("r3f3")
//            debug("oRec = "+oRec)
            
//          // aGet Record
//            oRec = oJST.agetRecord("r3f3x")
//            debug("oRec = "+oRec)
           
          // Add Record
            oJST.addRecord(["r3f1_new", "r3f2", "r3f3"])
            
          // Get Record Index
            iRec = oJST.getRecordIndex("r3f3")
            pc("iRec = "+iRec)
            oRec = oJST[iRec]
            pc(
                    "oRec = "+oRec.dump()
                +"\n iRec = "+iRec
                +"\n Recs = "+oJST.length
            )
            
          // Add Record
            oJST.addRecord(["r3f1_new2", "r3f2", "r3f3"])
            
          // Get Record Index
            iRec = oJST.getRecordIndex("r3f3")
            pc("iRec = "+iRec)
            oRec = oJST[iRec]
            pc(
                   " oRec = "+oRec.dump()
                +"\n iRec = "+iRec
                +"\n Recs = "+oJST.length
            )
            
//          // Get Non Existing Record Index
//            iRec = oJST.agetRecordIndex("r3f3x")
//            debug("iRec = "+iRec)
           
        }

        
    </script>
</head>

<body>
	<script>
        bConsole=true; __qcOpts={cb:true, t:0, w: 600, h: 500}
	    _SCR_START=" bodyLoaded();"; function __start() {try{if(bConsole){startCons(__qcOpts); _w.consoleLoaded = function consoleLoaded(){ setTimeout(_SCR_START,50) }}else{eval(_SCR_START)}}catch(e){debugErr(e)}};__start()
    </script>
</body>
</html>